﻿<!DOCTYPE html>
<html ng-app="app">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1">
    <title>用户注册</title>
    <link rel="stylesheet" type="text/css" href="#(assets)/web/css/base.css">
    <link rel="stylesheet" type="text/css" href="#(assets)/web/css/main.css">
</head>
<body>
    <div class="bgfff100 top">
        <div class="wrapper">
            <span class="left">客服热线：400-123-1234（工作时间：9:00-17:00）</span>
            <span class="right"><a href="../user/login.html">登录</a><em>|</em><a href="../user/register.html">注册</a></span>
        </div>
    </div>
    <div class="bgfff100">
        <div class="menu wrapper">
            <a href="../index/index.html"><img class="logo" src="#(assets)/web/images/public/logo.png" /></a>
        </div>
    </div>
    <div class="bgfff100">
        <div class="wrapper register">
            <div class="left">
                <form id="form_login" onsubmit="return loginApi.loginFun();">
                    <p class="title">欢迎注册<span>已有账号？<a href="login.html">登录</a></span></p>
                    <p class="inputBox"><i class="ico1"></i><input type="text" placeholder="手机号" class="boxStyle1 info" id="mobile" /><em class="tip tip1"></em></p>
                    <p class="inputBox"><i class="ico2"></i><input type="password" placeholder="登录密码" class="boxStyle1 info" id="password" /><em class="tip tip2"></em></p>
                    <p class="inputBox"><i class="ico3"></i><input type="text" placeholder="输入手机验证码" class="boxStyle2 info" id="sms" /><input type="button" onclick="loginApi.getCode(this,1)" value="获取验证码" class="getCode" /><em class="tip"></em></p>
                    <p class="tjTxt">推荐人手机号码（选填）</p>
                    <p class="inputBox"><i class="ico1"></i><input type="text" placeholder="推荐人手机号码" class="boxStyle1" id="referee" /><em class="tip tip11"></em></p>
                    <p class="inputBox"><i class="ico3"></i><input type="text" placeholder="输入手机验证码" class="boxStyle2" id="sms2" /><input type="button" onclick="loginApi.getCode(this,2)" value="获取验证码" class="getCode" /></p>
                    <p class="agree"><input type="checkbox" id="agreeSelect" /><label for="agreeSelect">我已阅读并同意 <span>《未了财富网站服务协议》</span></label></p>
                    <input type="submit" value="立即注册" class="submitBtn" />
                </form>
            </div>
            <div class="right">
                <img src="#(assets)/web/images/user/registerImg.jpg" />
            </div>
        </div>
    </div>

    <div class="wrapper bottom">
        <div class="copyright">2016 未了财富 All right reserved   |   深圳前海大秦投资管理有限公司   |   粤ICP备16044335号-1</div>
        <div class="anbei"><span>浙公网安备 330502000108</span></div>
    </div>
    <script type="text/javascript" src="#(assets)/web/js/jquery.min.js"></script>
    <script type="text/javascript" src="#(assets)/web/js/layer/layer.js"></script>
    <script type="text/javascript" src="#(assets)/web/js/angular.min.js"></script>
    <script type="text/javascript" src="#(assets)/web/js/base.js"></script>
    <script type="text/javascript">
        var mobileYzPass = false;
        var passYzPass = false;
        var countdown = 60;
        var isSubmit = true;
        //是否允许提交
        var sfyxtj = true;
        var loginApi = {
            //点击登录
            loginFun: function () {
                var mobile = $("#mobile").val();
                var password = $("#password").val();
                var sms = $("#sms").val();
                $(".left .info").each(function (index) {
                    var tip = $(this).parent().find(".tip");
                    if ($(this).val() == "") {
                        layer.tips('必填', tip, {
                            tips: [2, '#40cab5']
                        });
                        return false;
                    } else {
                        if (index == 0) {
                            return loginApi.checkMobile(mobile,1);
                        } else if (index == 1) {
                            return loginApi.checkPass(password);
                        }
                        if (isSubmit) {
                            isSubmit = false;
                            var updata = new Object();
                            updata.mobile = $("#mobile").val();
                            updata.password = $("#password").val();
                            updata.sms = $("#sms").val();
                            updata.type = "web";
                            updata.referee = $("#referee").val();
                            updata.sms2 = $("#sms2").val();
                            ajax("$path$/user/reg", updata, function (data) {
                                if (data.code == 'success') {
                                    layer.msg(data.msg, { icon: 1, time: 1000 }, function () {
                                        window.location.href = "#(path)/user-useregauth";
                                    });
                                } else {
                                    layer.msg(data.msg, { icon: 2, time: 1000 });
                                }
                            })
                        }
                    }
                })
            },
            //获取验证码
            getCode: function (dom, i) {
                if (i == 1 && loginApi.checkMobile($("#mobile").val(),1)) {
                    ajax("/sys/sendCode?aes=0&type=reg", { "mobile": $("#mobile").val() }, function (data) {
                        if (data.code == "success") {
                            loginApi.time(dom);
                        } else {
                            layer.msg(data.msg, { icon: 2, time: 1000 });
                        }
                    });
                } else if (i == 2 && loginApi.checkMobile($("#referee").val(), 11)) {
                    loginApi.time(dom);
                    ajax("/sys/sendCode?aes=0&type=reg", { "referee": $("#referee").val() }, function (data) {
                        if (data.code == "success") {
                            loginApi.time(dom);
                        } else {
                            layer.msg(data.msg, { icon: 2, time: 1000 });
                        }
                    });
                }
            },
            //验证手机
            checkMobile: function (mobile, i) {
                mobileYzPass = false;
                var mobileYz = /^[1][3,4,5,7,8][0-9]{9}$/;
                if (mobile == "") {
                    layer.tips('必填', ".tip"+i, {
                        tips: [2, '#40cab5']
                    }); 
                } else if (mobile != "" && !mobileYz.test(mobile)) {
                    layer.tips('手机格式不正确', ".tip" + i, {
                        tips: [2, '#40cab5']
                    });
                } else {
                    mobileYzPass = true;
                }
                return mobileYzPass;
            },
            //验证密码
            checkPass: function (password) {
                passYzPass = false;
                var passwordYz = /^[_0-9a-zA-Z\u4e00-\u9fa5]{1,10}$/;
                if (password == "") {
                    layer.tips('必填', ".tip2", {
                        tips: [2, '#40cab5']
                    })
                } else if (password != "" && !passwordYz.test(password)) {
                    layer.tips('密码只能为数字或字母', ".tip2", {
                        tips: [2, '#40cab5']
                    });
                } else {
                    passYzPass = true;
                }
                return passYzPass;
            },
            //倒计时
            time: function (val) {
                if (countdown == 0) {
                    val.removeAttribute("disabled");
                    val.value = "重新发送";
                    val.className = "getCode"
                    countdown = 60;
                } else {
                    val.setAttribute("disabled", true);
                    val.value = "" + countdown + "后重新发送";
                    val.className = "getCode getCode2"
                    countdown--;
                    setTimeout(function () {
                        loginApi.time(val);
                    }, 1000)
                }
            }
        }
    </script>
</body>
</html>